﻿/// <Summary> 
/// $Author: 
/// Refered from DynamicDataDisplay project on codeplex: http://dynamicdatadisplay.codeplex.com/releases/view/26761

/// $Creation Date : 
/// </summary>
/// 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Research.DynamicDataDisplay.Common;
using System.Diagnostics;
using MindTree.PerfWorkbench.Azure.Monitor.Core;


namespace MindTree.PerfWorkbench.Azure.Monitor.AzureMonitor
{
    /// <summary>
    /// This class represents data structure for single result entity to be shown in the grph for a counter
    /// </summary>
    public class PerformanceInfo
    {
        public DateTime Time { get; set; }
        public double Value { get; set; }
    }

    /// <summary>
    /// This class defines data structure for holding the graph data. It extends RingArray
    /// </summary>
    public class PerformanceData : RingArray<PerformanceInfo>
    {
        private readonly PerfCounter counter;


        public PerformanceData(string machineName, string categoryName, string counterName, string instance) : this(new PerfCounter( machineName,categoryName, counterName, instance)) { }

        public PerformanceData(PerfCounter counter)
            : base(200)
        {
            if (counter == null)
                throw new ArgumentNullException("counter");

            this.counter = counter;
        }

        /// <summary>
        /// Add a new data in the graph data source
        /// </summary>
        /// <param name="paramRowInfo">Single result instance</param>
        public void UpdateDataRow(PerformanceInfo paramRowInfo)
        {
            var newInfo = new PerformanceInfo { Time = paramRowInfo.Time, Value = paramRowInfo.Value };            
            this.Add(newInfo);
        }
    }
}
